//
//  MyInformation.m
//  MINFOBBS
//
//  Created by juvid on 13-12-9.
//  Copyright (c) 2013年 minfo. All rights reserved.
//

#import "MyInformation.h"
#import "DetectionSystemVersion.h"
#import "EditMyInformation.h"
#import "UIColor+expanded.h"
@interface MyInformation ()

@end

@implementation MyInformation

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.view.backgroundColor=[UIColor colorWithRed:243/255.0 green:243/255.0 blue:243/255.0 alpha:1];
    if ([[DetectionSystemVersion alloc]Version]) {
        self.edgesForExtendedLayout=UIRectEdgeNone;
    }
    arrCell=[[NSArray alloc]initWithObjects:@"昵称",@"姓名",@"性别",@"生日",nil];
    arrUser=[[NSMutableArray alloc]initWithObjects:@"",@"",@"男",@"1990-1-1", nil];
      NSUserDefaults *use=[NSUserDefaults standardUserDefaults];
    if ([use objectForKey:@"userInfor"]) {
        arrUser=[[NSMutableArray alloc]initWithObjects:[[use objectForKey:@"userInfor"]objectForKey:@"user"],[[use objectForKey:@"userInfor"]objectForKey:@"name"],[[use objectForKey:@"userInfor"]objectForKey:@"sex"],[[use objectForKey:@"userInfor"]objectForKey:@"born"], nil];
    }
    self.table.layer.cornerRadius=5.0;
    [self BackButton];
    
    // Do any additional setup after loading the view from its nib.
}
-(void)viewDidAppear:(BOOL)animated{
    NSUserDefaults *use=[NSUserDefaults standardUserDefaults];
    if ([use objectForKey:@"userInfor"]) {
        arrUser=[[NSMutableArray alloc]initWithObjects:[[use objectForKey:@"userInfor"]objectForKey:@"user"],[[use objectForKey:@"userInfor"]objectForKey:@"name"],[[use objectForKey:@"userInfor"]objectForKey:@"sex"],[[use objectForKey:@"userInfor"]objectForKey:@"born"], nil];
    }
    [self.table reloadData];
}
-(void)BackButton{
    self.navigationItem.titleView=[DetectionSystemVersion SetBarTitle:@"百事搜"];
    [self.navigationItem setHidesBackButton:YES];
    UIButton *btnBack=[[DetectionSystemVersion alloc]BackButton];
    [btnBack addTarget:self action:@selector(BackReturn:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *backItem = [[UIBarButtonItem alloc]initWithCustomView:btnBack];
    self.navigationItem.leftBarButtonItem=backItem;
    
}
#pragma mark 导航栏按钮事件
-(void)BackReturn:(id)sender{
    //    [self.navigationController.view removeFromSuperview];
    [self HidePick:self.navigationController.view];
    [self.navigationController removeFromParentViewController];
}
#pragma mark 动画
-(void)HidePick:(UIView *)vieBounced {
    [UIView animateWithDuration:0.3
                     animations:^(void) {
                         vieBounced.alpha = 0.0;
                         //                         vieBounced.frame = CGRectMake(0, self.view.frame.size.height, 104, (self.view.frame.size.height-117-8)/3);
                     } completion:^(BOOL finished) {
                         
                         [vieBounced removeFromSuperview];
                     }];
    
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    //#warning Potentially incomplete method implementation.
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    //#warning Incomplete method implementation.
    // Return the number of rows in the section.
    return 4;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
//        cell.backgroundColor=[UIColor grayColor];
    }
    cell.selectionStyle=UITableViewCellSelectionStyleNone;
//    cell.accessoryView=lab;
    cell.indentationLevel=1;
    cell.indentationWidth=15.0;
    cell.textLabel.text=[arrCell objectAtIndex:indexPath.row];
    cell.textLabel.font=[UIFont systemFontOfSize:15];
    cell.textLabel.textColor=[UIColor colorWithHexString:@"0x474747"];
    UIView *vie=[[UIView alloc]initWithFrame:CGRectMake(120, 0, 160, 44)];
    UILabel  *lab=[[UILabel alloc]initWithFrame:CGRectMake(0, 7, 150, 30)];
    lab.text=[NSString stringWithFormat:@"%@    ",[arrUser objectAtIndex:indexPath.row]];
    lab.font=[UIFont systemFontOfSize:15];
    lab.textAlignment=NSTextAlignmentRight;
    [vie addSubview:lab];
    cell.accessoryView=vie;
//    [cell.contentView addSubview:lab];
    return cell;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)PressEdit:(id)sender {
    EditMyInformation *editInfor=[[EditMyInformation alloc]init];
    [self.navigationController pushViewController:editInfor animated:YES];
}
@end
